package learn.arc;

import io.netty.util.HashedWheelTimer;
import io.netty.util.concurrent.ImmediateEventExecutor;
import org.redisson.RedissonBaseLock;
import org.redisson.RedissonLock;
import org.redisson.RedissonLockEntry;
import org.redisson.api.RFuture;
import org.redisson.misc.AsyncSemaphore;
import org.redisson.pubsub.LockPubSub;

import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

public class Redisson {

    /**
     *
     */
    public static void lock() throws InterruptedException {
        RedissonLock redissonLock=null;
        redissonLock.tryLock(100,10, TimeUnit.SECONDS);

        // 等待；订阅。初次唤醒，发布时；其后，Semaphore唤醒
        RFuture<RedissonLockEntry> subscribeFuture=redissonLock.subscribe(0L);
        {
            LockPubSub lps = new LockPubSub();
            lps.subscribe(null, null);
            AsyncSemaphore s1;// 多线程协调，立即执行；确保进程内单线程进行
            RedissonLockEntry e1 = LockPubSub.createEntry(null);
        }
        subscribeFuture.await(1, null);// 等待
        {
            ImmediateEventExecutor.ImmediatePromise i1=null;
            i1.await(1, null);// 发布时唤醒
        }
        Semaphore s2;// 非初次唤醒

        // 自动续期
        RedissonBaseLock.ExpirationEntry e1;// 过期信息；包含线程id-重入次数、定时任务
        HashedWheelTimer h1;// 时间轮

    }
}
